package main

import (
	"flag"
	"fmt"

	"charging_pile/cron/internal/config"
	"charging_pile/cron/internal/cronx"

	cron "github.com/robfig/cron/v3"
	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/core/logx"
)

var configFile = flag.String("f", "etc/device.yaml", "the config file")

func main() {
	flag.Parse()
	var c config.Config

	conf.MustLoad(*configFile, &c)

	logx.DisableStat()

	if err := c.SetUp(); err != nil {
		panic(err)
	}

	cr := cron.New(cron.WithSeconds())

	ScheduleRun(cr)

}

func ScheduleRun(c *cron.Cron) {
	c.AddFunc(cronx.EveryHalfHour(), func() {
		fmt.Println("定时任务")
	})
	// 每分钟定时查询用户信息
	// c.AddFunc(cronx.Every5s(), userlist)

	// 计划任务执行写在这里
}
